import { defineStore } from "pinia"
import { ref } from "vue"
import { getColorArray } from "@/utils/color"
export const useThemeStore = defineStore("themeStore", () => {
 const currentColorArray = ref<string[]>()
  // 根据颜色组更新当前颜色组
  const updateCurrentColorByArray = (color: string[]) => {
    currentColorArray.value = color
  }
   // 根据颜色更新当前颜色组
   const updateCurrentColorArray = (color: string) => {
    const { newPalette, brandColorIndex } = getColorArray(color)
    const firstColor = newPalette[0]
    const primaryColor = newPalette[brandColorIndex]
    newPalette[0] = primaryColor
    newPalette[brandColorIndex] = firstColor
    currentColorArray.value = newPalette
  }


  return {
    updateCurrentColorByArray,
    updateCurrentColorArray,
    currentColorArray
  }
})
